package com.raquel.rachelgame;



import android.os.Bundle;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MenuActivity extends ListActivity {
	private String[] activities={"Game","Preferences","Help"};
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//setContentView(R.layout.activity_menu);
		setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, activities));
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.menu, menu);
		return true;
	}
	
	@Override
	protected void onListItemClick(ListView list, View view, int position, long id){
		super.onListItemClick(list, view, position, id);
		String testName= activities[position];
		try{
			Class clase = Class.forName("com.raquel.rachelgame."+ testName+"Activity");
			Intent intent = new Intent(this,clase);
			startActivity(intent);
			MenuActivity.this.finish();
		}catch(ClassNotFoundException e){
			e.printStackTrace();
		}
	}

}
